
#include "runtime_types.h"
#include "util.h"

uint32
runtime_fastrand1(void)
{
	// FIXME: multithreading
	
	static uint32 fastrand = 0x49f6428aUL;
	
	fastrand += fastrand;
	if(fastrand & 0x80000000L)
		fastrand ^= 0x88888eefUL;
	return fastrand;
}

int32
runtime_atoi(const byte *p)
{
	int32 n;

	n = 0;
	while('0' <= *p && *p <= '9')
		n = n*10 + *p++ - '0';
	return n;
}

/*
const byte*
runtime_getenv(const char *s)
{
	int32 i, j, len;
	const byte *v, *bs;
	String* envv;
	int32 envc;

	bs = (const byte*)s;
	len = runtime_findnull(bs);
	envv = (String*)syscall_Envs.__values;
	envc = syscall_Envs.__count;
	for(i=0; i<envc; i++){
		if(envv[i].__length <= len)
			continue;
		v = (const byte*)envv[i].__data;
		for(j=0; j<len; j++)
			if(bs[j] != v[j])
				goto nomatch;
		if(v[len] != '=')
			goto nomatch;
		return v+len+1;
	nomatch:;
	}
	return nil;
}
*/
